package net.zjitc.response;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author Administrator
 * @Date 2020/5/21 14:34
 * 重定向
 * 1.浏览器访问redirectDemo1
 * redirectDemo1操作；
 * 重定向到redirectDemo2
 * （响应码302，location头-——》简化成；sendRedirect()）
 **/
@WebServlet("/redirectDemo1")
public class RedirectDemo1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /* 重定向到redirectDemo2
         * （响应码302，location头-——》简化成；sendRedirect()）
         */
        resp.sendRedirect("/dome/redirectDemo2");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
